<template>
  <div class="content">
    <div class='father'>
      <p style='text-align: left;'> <img :src="'./static/image/gold'+id+'.png'" alt=""></p>
      <div class='son'>
        <div ref='sunzii' :class='{"sunzi gold":id=="2","sunzi ying":id=="3","sunzi tong":id=="4",}'>
          <p>当前{{progress}}%</p>

        </div>
      </div>
      <p>当前：{{Math.floor(progress*10000)/100}}/10000</p>
    </div>
  </div>
</template>

<script>
import $ from "jquery";
import { setTimeout } from "timers";
export default {
  data() {
    return {
      progress: 0,
      id: u.getStore("istype")
    };
  },
  methods: {
    bar() {
      this.$refs.sunzii.style.width = "100%";
    }
  },
  created() {
    let time = setInterval(() => {
      if (u.flag) {
        clearInterval(time);
        u.findActivityPercent({ activityId: u.getStore("gamdId") }, data => {
          if (data && data[0].code == "200") {
            let progress =  parseInt(data[0].data);
            this.$refs.sunzii.style.width =  progress / 1.061 + "%";
            let timmer = setInterval(() => {
              if (this.progress >= progress) {
                if (this.progress == 100) {
                  this.$parent.pop_index = false;
                }
                this.progress = data[0].data;
                clearInterval(timmer);
                return;
              }
              this.progress++;
            }, 30);
          }
        });
      }
    }, 10);
  },
  mounted() {}
};
</script>

<style scoped lang='less'>
.content {
  // height: 100vh;
  // width: 100vw;
  // background: url(../../static/image/ginsengbg2.png) no-repeat center center;
  // background-size: cover;
}
.father {
  height: 100px;
  width: 520px;
  position: absolute;
  top: 55%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 12px;
  box-sizing: border-box;
  .son {
    width: 100%;
    height: 70px;
    background: url(../../static/image/barbg.png) no-repeat center;
    .sunzi {
      position: relative;
      left: 13px;
      width: 0;
      background-size: 98% 58%;
      background-position-x: -10px;
      transition: width 2s;
      line-height: 70px;
      text-align: center;
      color: white;
      height: 27px;
      top: 22px;
      border-radius: 12px;
      // overflow: hidden;
      p {
        width: 520px;
        box-sizing: border-box;
        padding-left: 200px;
        text-align: left;
        top: -19px;
        position: relative;
      }
    }
    .gold {
      background: url(../../static/image/goldProgress.png) no-repeat center;
      background-size: 160% 200%;
    }
    .ying {
      background: url(../../static/image/yingProgress.png) no-repeat center;
      background-size: 160% 200%;
      text-shadow: 1px 1px 1px rgba(197, 197, 197, 0.75),
        1px -1px 1px rgba(197, 197, 197, 0.75);
    }
    .tong {
      background: url(../../static/image/tongProgress.png) no-repeat center;
      background-size: 160% 200%;
      text-shadow: 1px 1px 1px rgba(255, 137, 68, 0.75),
        1px -1px 1px rgba(255, 137, 68, 0.75);
    }
  }

  p {
    font-size: 16px;
    color: white;
    padding-left: 10px;
    text-shadow: 0 2px #3a230a, -1px 0 #3a230a, -2px 2px #3a230a,
      -2px 1px #3a230a;
    text-align: center;
  }
}
</style>
